package com.xiaoxi.checkpasswordserver.domain;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

/**
 * @ClassName ConfirmPasswordCheck
 * @Description
 * @Author xiaoxi
 * @Date 2022/7/11 21:53
 * @Version 1.0
 */
@Component
@Data
public class ConfirmPasswordCheck implements IPasswordCheck {

    private String confirmPassword;

    @Override
    public CheckResult check(String password, CheckResult checkResult) {
        if (StringUtils.isNotBlank(confirmPassword)) {
            if (!password.equals(confirmPassword)) {
                checkResult.getErrorReason().add("密码不一致");
            }
        }
        return checkResult;
    }
}
